package equation;

public class SubEquation extends Equation {

    public SubEquation() {
        super("-");
    }

    public SubEquation(String equationStr) {
        int index = equationStr.indexOf("-");
        int length = equationStr.length();
        this.setLeftNum(Integer.parseInt(equationStr.substring(0,index)));
        this.setRightNum(Integer.parseInt(equationStr.substring(index+1,length-1)));
        this.setOp("-");
        this.setResult(calculate());
    }


    @Override
    protected int calculate() {
        return this.getLeftNum()-this.getRightNum();
    }
}
